<?php

include_once __DIR__ . '/../vendor/autoload.php';
include_once __DIR__ . '/../db.php';

$type = @$_GET['type'] ?: 1;
$dateStart = @$_GET['date__start'] ?: '';
$dateEnd = @$_GET['date__end'] ?: '';
$size = @$_GET['size'] ?: 10;

$query = \Data::where('type', $type);
if ($dateStart) {
    $query->where('date', '>=', $dateStart);
}
if ($dateEnd) {
    $query->where('date', '<=', $dateEnd);
}

$query->orderBy('date', 'desc');
$data = $query->paginate($size);

include __DIR__ . '/../admin.phtml';
